home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / CW GUSI 1.6.4 / Examples / GUSITest.h < prev    next >
Text File  |  1995-01-19  |  2KB  |  98 lines

  1. /*********************************************************************
  2. File        :    GUSI                -    Grand Unified Socket Interface
  3. File        :    GUSITest.h        -    Common testing gear
  4. Author    :    Matthias Neeracher <neeri@iis.ethz.ch>
  5. Language    :    MPW C
  6.  
  7. $Log: GUSITest.h,v $
  8. Revision 1.2  1994/12/31  01:18:29  neeri
  9. Benchmark support.
  10.  
  11. Revision 1.1  1994/02/25  02:48:06  neeri
  12. Initial revision
  13.  
  14. Revision 0.1  1992/09/08  00:00:00  neeri
  15. Factor out more common code
  16.  
  17. *********************************************************************/
  18.  
  19. #ifndef _GUSITEST_
  20. #define _GUSITEST_
  21.  
  22. typedef void (*TestCmd)(char ch1, char ch2, const char * restcmd);
  23.  
  24. #include "GUSITest_P.h"
  25.  
  26. #include <stdio.h>
  27.  
  28. extern FILE *  input;
  29. extern int        inputline;
  30.  
  31. /* void COMMAND(
  32.                  char ch1, char ch2,            Command name
  33.                 TestCmd p,                        Command to be run
  34.                 char *  s,                        Arguments to command
  35.                 char *  h);                        Explanation for command
  36.  
  37.     Example:
  38.         COMMAND('m', 'd', MkDir, "directory",            "Make a new directory");
  39. */
  40.  
  41. #define COMMAND(ch1,ch2,p,s,h)    \
  42.     DISPATCH(ch1,ch2)    =    (p),        \
  43.     USAGE(ch1,ch2)     =    (s),        \
  44.     HELPMSG(ch1,ch2)    =    (h)
  45.  
  46. /* An useful macro for dumping variables.
  47.     
  48.     Example:
  49.         DUMP(statbuf.st_dev,d);
  50. */
  51.  
  52. #define DUMP(EXPR, MODE)    printf("#    %s = %"#MODE"\n", #EXPR, EXPR)
  53.  
  54. /* Add common commands for sockets */
  55.  
  56. void AddSocketCommands();
  57.  
  58. /* Run the test. Define your commands with COMMAND and call this */
  59.  
  60. void RunTest(int argc, char ** argv);
  61.  
  62. /* Print a MPW executable location note */
  63.  
  64. void Where();
  65.  
  66. /* Print a prompt */
  67.  
  68. void Prompt();
  69.  
  70. /* Return a string of the current error number, e.g. "EINVAL" */
  71.  
  72. const char * Explain();
  73.  
  74. /* Print a usage message for a command */
  75.  
  76. void Usage(char ch1, char ch2);
  77.  
  78. /* Clean up sockets */
  79.  
  80. void CleanupSockets();
  81.  
  82. extern int sock;                /* Socket to read/write to                */
  83. extern int accsock;            /* Socket to accept connections on     */
  84.  
  85. /* Keep statistics on a series of values */
  86.  
  87. typedef struct {
  88.     int     count;
  89.     long    min;
  90.     long  max;
  91.     long    sum;
  92. } Sampler;
  93.  
  94. void InitSampler(Sampler * samp);
  95. void Sample(Sampler * samp, long sample);
  96.  
  97. #endif
  98.